Repository navigation
Keep the report subtree mounted when the linked action param changes - #104381
Conversation
LinkedActionNotFoundGuard returned bare children without a linked action and wrapped them in a keyed gate with one, so setting, changing or clearing reportActionID remounted the header, actions list and composer. Sending the first message from a chat opened at a linked action clears the param, and the remounted composer was reseeded with the not-yet-cleared draft. Render the gate as a sibling after children so the subtree keeps its position, while the gate still resets per linked action and its recovery effects still run after the children's effects. Co-authored-by: Nyoman Jyotisa <nyomanjyotisa@users.noreply.github.com>
|
I opened this PR from a branch in the main App repo because you don't have a fork of To take ownership of the branch and push updates, run: Then you can close this PR and open a new one from your fork. |
|
🤖 Web test steps verification results: ✅ pass The PR's Tests section is still empty, so I ran the repro steps from [$175] Android-Chat-Message reappear in composer when sent to chat with unapproved expense with one account. After the chat opened at the linked expense action, both sent messages posted and the composer stayed empty. I could not read the browser console, so the console-error step is partial.
|
|
🤖 Android test steps verification results: ✅ pass On Android, I opened the workspace chat at a linked expense action and sent two messages. Both times the composer stayed empty and the chat jumped to the latest messages. The PR's Tests section is still empty, so I ran the one-account version of the repro steps from [$175] Android-Chat-Message reappear in composer when sent to chat with unapproved expense.
|
|
@puneetlath While testing this PR, I discovered a pre-existing bug and confirmed it on main: sending offline from an older linked expense hides the queued message until reconnect. A four-line local fix restores visibility (18 lines including regression tests). May I handle this separately under the C+ small-fix process? |
|
@MelvinBot please replace Updated testing, checklist, and recordingsTests
Offline tests
QA StepsSame as Tests and Offline tests. Do not approve or pay the test expense.
PR Author Checklist
Screenshots/VideosAndroid: NativePR-104381-android-native-online.mp4Android: mWeb ChromePR-104381-android-mweb-chrome-online.mp4iOS: NativePR-104381-ios-native-online.mp4iOS: mWeb SafariPR-104381-ios-mweb-safari-online.mp4MacOS: Chrome / SafariPR-104381-desktop-web-chrome-aligned-online.mp4 |
|
I updated the PR description. Everything from |
Sure, sounds good. |
|
@MelvinBot please mark this PR ready for review. |
|
I marked this PR ready for review. |
|
@nyomanjyotisa Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppPR-104381-android-native-online.mp4Android: mWeb ChromePR-104381-android-mweb-chrome-online.mp4iOS: HybridAppPR-104381-ios-native-online.mp4iOS: mWeb SafariPR-104381-ios-mweb-safari-online.mp4MacOS: Chrome / SafariPR-104381-desktop-web-chrome-aligned-online.mp4 |
| // The gate is a sibling rather than a wrapper so that setting, changing or clearing the linked action never remounts | ||
| // the report subtree (header, actions list, composer) and drops its local state, e.g. the composer text. | ||
| // It comes after children so its recovery effects still run after theirs, as they did when it wrapped them. |
There was a problem hiding this comment.
Can we remove the historical context of "as they did when it wrapped them" here. No who reads this in the future is going to know what that means. In general, if we could make this comment more succinct and straightforward that would be great.
There was a problem hiding this comment.
Done in 24651122. I removed the historical context and shortened the comment to two lines:
// Render the gate next to children, not around them, so changing the linked action doesn't remount the report
// and lose its state (e.g. composer text). It comes after children so its effects run after theirs.| // The gate no longer re-renders when its parent does, only when its own subscriptions change, so the useOnyx mock | ||
| // notifies subscribers like Onyx does. Visibility is derived from DERIVED.VISIBLE_REPORT_ACTIONS, so an update | ||
| // also replaces that value. |
There was a problem hiding this comment.
Again, let's remove historical context here and just provide the information necessary to understand the code as-written now.
There was a problem hiding this comment.
joekaufmanexpensify
left a comment
There was a problem hiding this comment.
Good for product
|
@MelvinBot please address @puneetlath’s comment-wording requests here and here, with no runtime changes. |
Co-authored-by: Nyoman Jyotisa <nyomanjyotisa@users.noreply.github.com>
|
@nyomanjyotisa Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
I made both wording changes
I also replied in both review threads. |
|
🚀 Deployed to staging by https://github.com/puneetlath in version: 9.5.20-0 🚀
|
|
No help site update needed. This PR fixes a bug where a sent message reappeared in the composer after you opened a chat at a linked action, so the app now behaves the way users already expect. |
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.5.20-5 🚀
Bundle Size Analysis (Sentry): |






Explanation of Change
When a chat opens at a linked action (for example, the unapproved expense the inbox scrolls to), the first message you send jumps to the live tail and clears
reportActionID.LinkedActionNotFoundGuardreturned barechildrenwithout a linked action but wrapped them in a keyedLinkedActionNotFoundGatewith one, so clearing the param changed the tree shape and remounted the header, actions list and composer. The remounted composer read its starting text from the report draft before the debounced clear had written it, so the sent message came back.This renders the gate as a sibling that returns
null, placed afterchildren:reportActionIDno longer remounts the report subtree, so the composer and other local state survive (this matches how the screen behaved before the guards were extracted).key={reportActionIDFromRoute}, so it still resets per linked action.Tests in
tests/navigation/LinkedActionNotFoundGuardTest.tsx:main. The ordering test fails if the gate is moved beforechildren.useOnyxmock now notifies subscribers, so the existing deleted/removed/loading tests push changes the way Onyx does instead of relying on a parent re-render.AI tests run locally:
npm testontests/navigation,useReportActionsScrollTest,useReportActionsNewActionLiveTailTest,PaginationTest,ReportActionComposeTest,ReportActionItemMessageEditTest,ReportActionMessageEditLayoutTestandMoneyRequestReportPreview: 71 suites, 842 tests passed.npm run lint-changed,npm run typecheck,npm run spell-changedandnpm run fmt(no diff): passed.react-compiler-compliance-check checkon the guard: exited cleanly.check-changedcouldn't run in this environment because the base ref was empty.Fixed Issues
$ #104358
PROPOSAL: #104358 (comment)
Tests
Offline tests
QA Steps
Same as Tests and Offline tests. Do not approve or pay the test expense.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
PR-104381-android-native-online.mp4
Android: mWeb Chrome
PR-104381-android-mweb-chrome-online.mp4
iOS: Native
PR-104381-ios-native-online.mp4
iOS: mWeb Safari
PR-104381-ios-mweb-safari-online.mp4
MacOS: Chrome / Safari
PR-104381-desktop-web-chrome-aligned-online.mp4